---------------------------------------------------
-- Pet Ability: Perfect Defense
-- Reduces damage sustained by party members and
-- prevent status ailments. Damage reduction and
-- resistance rate will vary with the summoner’s
-- remaining MP. 
---------------------------------------------------

require("/scripts/globals/settings");
require("/scripts/globals/status");
require("/scripts/globals/monstertpmoves");

---------------------------------------------------

function OnAbilityCheck(player, target, ability)
	return 0,0;
end;

function OnPetAbility(target, pet, skill, master)
	local power = 100 * (master:getMP() / master:getMaxMP());
	duration = 60;
	if (master ~= nil) then
		local summoningSkill = master:getSkillLevel(SKILL_SUM);
		if (summoningSkill > 600) then
			summoningSkill = 600;
		end
		duration = 30 + summoningSkill / 20;
	end
	target:delStatusEffect(EFFECT_PERFECT_DEFENSE);
	target:addStatusEffect(EFFECT_PERFECT_DEFENSE,power,3,duration);
	skill:setMsg(MSG_BUFF);
	return EFFECT_PERFECT_DEFENSE;
end